import ajax from '@/utils/ajax';

export function doLogin(data) {
  return ajax({
    url: '/protal/sso/login',
    method: 'post',
    data
  });
}

export function doLogout() {
  return ajax({
    url: '/protal/sso/logout'
  });
}

export function doRegist(data) {
  return ajax({
    url: '/protal/sso/register',
    method: 'post',
    data
  });
}

export function doUpdatePwd(data) {
  return ajax({
    url: '/protal/sso/updatePassword',
    method: 'post',
    data
  });
}

export function doCheckAuthcode(data) {
  return ajax({
    url: '/protal/sso/checkAuthcode',
    method: 'post',
    data
  });
}

export function doSmsCode(params) {
  return ajax({
    url: '/protal/sso/getAuthCode',
    params
  });
}
export async function doVerifyUser(token) {
  if (!token) return false;
  const res = await ajax({
    url: '/protal/sso/verify/login',
    params: { token: token }
  });
  return res.code === 200;
}

export async function doGetUsername(id) {
  return ajax({
    url: '/protal/websocket/get/username/by/id',
    params: { id }
  });
}
